'use strict';
const base = require('./base');
const moment = require('moment');
module.exports = app => {
  const { STRING, INTEGER,DECIMAL,DATE } = app.Sequelize;

  const Manage = app.model.define('manage',
    Object.assign(base(app), {
      id: { type: INTEGER, primaryKey: true, autoIncrement: true },
      pic: STRING(64),
      num: STRING(64),
      name: STRING(64),
      property: STRING(32),
      sequence: STRING(32),
      type: STRING(32),
      status: STRING(32),
      mode: STRING(32),
      principal: STRING(32),
      trademark: STRING(32),
      model: STRING(32),
      level: STRING(32),
      position: STRING(32),
      buy_time: {
        type: DATE,
        defaultValue: () => {
          return moment(Date.now()).format('YYYY-MM-DD HH:mm:ss');
        },
        get() {
          return moment(this.getDataValue('created_at')).format('YYYY-MM-DD HH:mm:ss');
        },
      },
      cost: DECIMAL(10,2),
      guarantee: {
        type: DATE,
        get() {
          return moment(this.getDataValue('created_at')).format('YYYY-MM-DD HH:mm:ss');
        },
      },
      commission: {
        type: DATE,
        get() {
          return moment(this.getDataValue('created_at')).format('YYYY-MM-DD HH:mm:ss');
        },
      },
      scrap: {
        type: DATE,
        get() {
          return moment(this.getDataValue('created_at')).format('YYYY-MM-DD HH:mm:ss');
        },
      },
      remark: STRING(64),
    }));
  return Manage;
};
